package com.mallcai.bigdata.ladon.vo;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-05-28 15:07.
 * Modify:
 */
@Data
public class MyPageInfo<T> {

    private List<T>    list;
    private Pagination pagination;

    public MyPageInfo(PageInfo<T> pageInfo) {
        if (pageInfo != null) {
            this.list = pageInfo.getList();
            this.pagination = new Pagination(
                    Integer.valueOf(pageInfo.getTotal() + ""), // 强转为Int
                    pageInfo.getPageSize(),
                    pageInfo.getPageNum()
            );
        } else {
            this.list = new ArrayList<>();
            this.pagination = new Pagination();
        }

    }
}
